<template>
  <BaseDialog title="查看素材" :handleCancel="handleCancel" v-model:dialogVisible="props.dialogVisible">
    <el-form ref="ruleFormRef" :model="props.form" label-width="100px" class="ruleForm" status-icon>
      <el-form-item label="所属分类">{{ props.form.typeName }} </el-form-item>
      <el-form-item label="素材名称">
        {{ props.form.materialName }}</el-form-item>
      <el-form-item label="内容"> {{ props.form.content }}</el-form-item>
      <el-form-item label="文件">
        <template v-if="props.form.fileDtoList && props.form.fileDtoList.length > 0">
          <FielsList :list="props.form.fileDtoList"></FielsList>
        </template>

      </el-form-item>
    </el-form>
    <FilesDetail v-if="fielsVisible" v-model:dialogVisible="fielsVisible" :url="fileUrl"></FilesDetail>
  </BaseDialog>
</template>
  
<script setup lang="ts">
import FilesDetail from '@/components/filesDetals.vue'
import { download } from '@/hooks/downLoad'
const props = defineProps({
  dialogVisible: {
    type: Boolean,
  },
  form: {
    type: Object,
  },
  handleSearch: {
    type: Function,
  },
})

const emit = defineEmits(['update:dialogVisible'])

const handleCancel = () => {
  emit('update:dialogVisible', false)
}

const fielsVisible = ref(false)

const fileUrl = ref('')

const handleSee = (url) => {
  fielsVisible.value = true
  console.log(url)
  fileUrl.value = url
}
const getFileType = (url) => {
  if (url) {
    const arr = url.split('.')
    const type = arr[arr.length - 1]
    if (type == 'jpg' || type == 'png') {
      return true
    }
  }
  return false
}
onMounted(() => { })
</script>
  
<style lang="scss" scoped>
:deep(.el-form-item__label) {
  justify-content: flex-end;
}
.files {
  display: flex;
  font-size: 12px;
  width: 100%;
  .name {
    flex: 1;
    width: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
}

</style>
  